package cc.mrbird.febs.cos.controller;


import cc.mrbird.febs.common.utils.R;
import cc.mrbird.febs.cos.entity.CarouselInfo;
import cc.mrbird.febs.cos.service.ICarouselInfoService;
import cc.mrbird.febs.cos.service.IContactService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author fanke
 */
@RestController
@RequestMapping("/cos/carousel-info")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class CarouselInfoController {

    private final ICarouselInfoService carouselInfoService;

    /**
     * 分页查询
     * @param page
     * @param carouselInfo
     * @return
     */
    @GetMapping("/page")
    public R getBooKInfoByPage(Page page, CarouselInfo carouselInfo) {
        return R.ok(carouselInfoService.page(page, Wrappers.query(carouselInfo)));
    }

    /**
     * 新增
     * @param carouselInfo
     * @return
     */
    @PostMapping
    public R save(CarouselInfo carouselInfo) {
        return R.ok(carouselInfoService.save(carouselInfo));
    }

    /**
     * 修改
     * @param carouselInfo
     * @return
     */
    @PutMapping
    public R update(CarouselInfo carouselInfo) {
        return R.ok(carouselInfoService.updateById(carouselInfo));
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @DeleteMapping("/{ids}")
    public R deleteByIds(@PathVariable("ids") List<Integer> ids) {
        return R.ok(carouselInfoService.removeByIds(ids));
    }
}
